package com.wu01.demo.controller;

import com.wu01.demo.Entity.OrderInfo;
import com.wu01.demo.Entity.PageRequest;
import com.wu01.demo.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderInfoController {
    @Autowired
    private OrderInfoService orderInfoService;
    private PageRequest pageQuery;

    @GetMapping(value = "findAll")
    public Object findAll(){
        return orderInfoService.findAll();
    }

    @GetMapping(value="/page")
    @ResponseBody
    public Object findPage(PageRequest pageQuery) {
        return orderInfoService.findPage(pageQuery);
    }
    @PostMapping(value="/page")
    @ResponseBody
    public Object savePage(PageRequest pageQuery) {
        return orderInfoService.savePage(pageQuery);
    }
    @PutMapping(value="/page")
    @ResponseBody
    public Object updatePage(PageRequest pageQuery) {
//        return orderInfoService.updatePage(pageQuery);
        return null;
    }
    @DeleteMapping(value="/page")
    @ResponseBody
    public Object deletePage(PageRequest pageRequest) {
        return orderInfoService.deletePage(pageRequest);
    }
    @PostMapping("/orderInfo")
    @ResponseBody
    public String addOrder(OrderInfo orderInfo){
        System.out.println(orderInfo);
        orderInfoService.addOrder(orderInfo);
        return orderInfo.toString();
    }
}